package com.example.mdc.logback.design_pattern.singleton;

/**
 * Author:      liu_pc
 * Date:        2023/8/15
 * Description: 懒汉单例
 * Version:     1.0
 */
public class LazySingleton {

    private static volatile LazySingleton instance;

    public LazySingleton() {

    }

    public static LazySingleton getInstance() {
        if (instance == null) {
            synchronized (LazySingleton.class) {
                if (instance == null) {
                    instance = new LazySingleton();
                }
            }
        }
        return instance;
    }

    public static void main(String[] args) {
        LazySingleton test = LazySingleton.getInstance();
    }
}
